import $http from '@/utils/http'
import { put,takeEvery,call } from 'redux-saga/effects'
import {LOADLIST,GETLIST,LOADSHOES,GETSHOES,LOADCLOTHES,GETCLOTHES} from './actionType'

//saga中间件中做axios请求
function* foo(){
    let recommend=yield call($http.get,{
        url:'recommend.json'
    })
    let shoes=yield call($http.get,{
        url:'shoes.json'
    })
    let clothes=yield call($http.get,{
        url:'clothes.json'
    })
    yield put({
        type:LOADLIST,
        list:recommend.data.data.hotList
    })
    yield put({
        type:LOADSHOES,
        shoes:shoes.data.data.list
    })
    yield put({
        type:LOADCLOTHES,
        clothes:clothes.data.data.list
    })

    // console.log(shoes);
}

function* saga(){
    yield takeEvery(GETLIST,foo)
    yield takeEvery(GETSHOES,foo)
    // yield takeEvery(GETCLOTHES,foo)
}
export default saga